# -*- mode: python -*-

Import(
    [
        "env",
        "have_sasl_lib",
        "http_client",
        "version_extra",
        "version_parts",
    ]
)

env = env.Clone()

env.SConscript(
    must_exist=1,
    dirs=[
        "client",
        "commands",
        "query",
    ],
    exports=[
        "env",
    ],
)


if env.TargetOSIs("windows"):
    generatedServerManifest = env.Substfile(
        "mongos.manifest.in",
        SUBST_DICT=[
            ("@mongo_version_major@", version_parts[0]),
            ("@mongo_version_minor@", version_parts[1]),
            ("@mongo_version_patch@", version_parts[2]),
            ("@mongo_version_extra@", version_parts[3]),
            ("@mongo_version_extra_str@", version_extra),
        ],
    )

    env.Alias("generated-sources", generatedServerManifest)
    env.Depends("mongos.res", generatedServerManifest)

env.BazelProgram(
    target="mongos",
    source=[],
    LIBDEPS=[],
    AIB_COMPONENT="mongos",
    AIB_COMPONENTS_EXTRA=[
        "core",
        "default",
        "devcore",
        "dist",
        "dist-test",
        "integration-tests",
        "servers",
    ],
)

env.CppUnitTest(
    target="multi_statement_transaction_requests_sender_test",
    source=[
        "multi_statement_transaction_requests_sender_test.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/db/s/shard_server_test_fixture",
        "$BUILD_DIR/mongo/db/session/session_catalog_mongod",
        "commands/cluster_commands",
        "sharding_api",
        "sharding_mongos_test_fixture",
    ],
)

env.CppUnitTest(
    target="s_test",
    source=[],
    LIBDEPS=[],
)

env.Benchmark(
    target="service_entry_point_router_role_bm",
    source=[
        "service_entry_point_router_role_bm.cpp",
    ],
    LIBDEPS=[
        "$BUILD_DIR/mongo/db/auth/authserver",
        "$BUILD_DIR/mongo/db/read_write_concern_defaults_mock",
        "$BUILD_DIR/mongo/db/service_context_non_d",
        "$BUILD_DIR/mongo/rpc/message",
        "startup_initialization",
    ],
)

env.CppUnitTest(
    target="service_entry_point_router_role_test",
    source=[],
    LIBDEPS=[],
)
